package com.lantu.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lantu.sys.entity.Score;
import com.lantu.sys.mapper.ScoreMapper;
import com.lantu.sys.service.ScoreService;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

@Service
public class ScoreServiceImpl extends ServiceImpl<ScoreMapper, Score> implements ScoreService {

    //查询所有的学成成绩信息
    @Override
    public IPage<Score> getScoreByOpr(Page<Score> pageParam, Score score) {
        QueryWrapper<Score> scoreQueryWrapper =new QueryWrapper<>();
        if(!StringUtils.isEmpty(score.getName())){
            scoreQueryWrapper.like("name",score.getName());
        }
        if(!StringUtils.isEmpty(score.getClazzName())){
            scoreQueryWrapper.like("clazz_name",score.getClazzName());
        }

        scoreQueryWrapper.orderByDesc("num");
        Page<Score> scorePage = baseMapper.selectPage(pageParam, scoreQueryWrapper);
        return scorePage;

    }

    @Override
    public List<Score> getallnum(String score) {
        QueryWrapper<Score> scoreQueryWrapper = new QueryWrapper<>();
        scoreQueryWrapper.select("name","num").eq("clazz_name",score);
        List<Score> scores = baseMapper.selectList(scoreQueryWrapper);

        return scores;
    }

    @Override
    public List getmaxnum(String score) {
        QueryWrapper<Score> scoreQueryWrapper = new QueryWrapper<>();
        scoreQueryWrapper.select("max(wuli)","max(huaxue)").eq("clazz_name",score);
        List scores = baseMapper.selectList(scoreQueryWrapper);
        return scores;
    }


}
